import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/base/JVxeTable/types';
import { getWeekMonthQuarterYear } from '/@/utils';

//列表数据
export const columns: BasicColumn[] = [
  {
    title: '需求计划编号',
    align: "left",
    dataIndex: 'demandPlanCode'
  },
  {
    title: '需求计划类型(0:劳务需求，1设备需求)',
    align: "left",
    dataIndex: 'demandPlanType'
  },
  {
    title: '提报人',
    align: "left",
    dataIndex: 'reportingUserName'
  },
  {
    title: '提报人联系方式',
    align: "left",
    dataIndex: 'reportingUserTel'
  },
  {
    title: '提报单位',
    align: "left",
    dataIndex: 'reportingUnit'
  },
  {
    title: '平台公司',
    align: "left",
    dataIndex: 'platformCompany'
  },
  {
    title: '接收平台公司(用户表id)',
    align: "left",
    dataIndex: 'platformCompanyId'
  },
  {
    title: '关联项目（取字典表sys_dict_item的id）',
    align: "left",
    dataIndex: 'relatedProject'
  },
  {
    title: '需求备注',
    align: "left",
    dataIndex: 'demandRemark'
  },
  {
    title: '劳务需求表/设备需求表demand_plan_id',
    align: "left",
    dataIndex: 'demandPlanId'
  },
  {
    title: 'process_instance_id',
    align: "left",
    dataIndex: 'processInstanceId'
  },
  {
    title: 'process_key',
    align: "left",
    dataIndex: 'processKey'
  },
  {
    title: 'process_status',
    align: "left",
    dataIndex: 'processStatus'
  },
  {
    title: 'process_location',
    align: "left",
    dataIndex: 'processLocation'
  },
  {
    title: '需求计划(目前只有月计划)',
    align: "left",
    dataIndex: 'demandPlan'
  },
  {
    title: '需求计划月份',
    align: "left",
    dataIndex: 'demandPlanMonth'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '需求计划编号',
    field: 'demandPlanCode',
    filedkey: 'cgcj_demand_plan_demand_plan_code',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入需求计划编号!' },
      ];
    },
    ifShow: ({ values }) => {
      return !values.id
    }
  },
  {
    label: '需求计划类型',
    field: 'demandPlanType',
    filedkey: 'cgcj_demand_plan_demand_plan_type',
    component: 'Select',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请选择需求计划类型!' },
      ];
    },
    componentProps: {
      options: [{
        label: '劳务需求',
        value: 0
      }, {
        label: '设备需求',
        value: 1
      }]
    }
  },
  {
    label: '提报人',
    field: 'reportingUserName',
    filedkey: 'cgcj_demand_plan_reporting_user_name',
    component: 'Input',
  },
  {
    label: '提报人联系方式',
    field: 'reportingUserTel',
    filedkey: 'cgcj_demand_plan_reporting_user_tel',
    component: 'InputNumber',
  },
  {
    label: '提报单位',
    field: 'reportingUnit',
    filedkey: 'cgcj_demand_plan_reporting_unit',
    component: 'Input',
  },
  {
    label: '平台公司',
    field: 'platformCompany',
    filedkey: 'cgcj_demand_plan_platform_company',
    component: 'Input',
  },
  {
    label: '接收平台公司(用户表id)',
    field: 'platformCompanyId',
    filedkey: 'cgcj_demand_plan_platform_company_id',
    component: 'Input',
  },
  {
    label: '关联项目（取字典表sys_dict_item的id）',
    field: 'relatedProject',
    filedkey: 'cgcj_demand_plan_related_project',
    component: 'Input',
  },
  {
    label: '需求备注',
    field: 'demandRemark',
    filedkey: 'cgcj_demand_plan_demand_remark',
    component: 'Input',
  },
  {
    label: '劳务需求表/设备需求表demand_plan_id',
    field: 'demandPlanId',
    filedkey: 'cgcj_demand_plan_demand_plan_id',
    component: 'Input',
  },
  {
    label: 'process_instance_id',
    field: 'processInstanceId',
    filedkey: 'cgcj_demand_plan_process_instance_id',
    component: 'Input',
  },
  {
    label: 'process_key',
    field: 'processKey',
    filedkey: 'cgcj_demand_plan_process_key',
    component: 'Input',
  },
  {
    label: 'process_status',
    field: 'processStatus',
    filedkey: 'cgcj_demand_plan_process_status',
    component: 'Input',
  },
  {
    label: 'process_location',
    field: 'processLocation',
    filedkey: 'cgcj_demand_plan_process_location',
    component: 'Input',
  },
  {
    label: '需求计划(目前只有月计划)',
    field: 'demandPlan',
    filedkey: 'cgcj_demand_plan_demand_plan',
    component: 'Input',
  },
  {
    label: '需求计划月份',
    field: 'demandPlanMonth',
    filedkey: 'cgcj_demand_plan_demand_plan_month',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];




// 高级查询数据
export const superQuerySchema = {
  demandPlanCode: { title: '需求计划编号', order: 0, view: 'text', type: 'string', },
  demandPlanType: { title: '需求计划类型(0:劳务需求，1设备需求)', order: 1, view: 'number', type: 'number', },
  reportingUserName: { title: '提报人', order: 2, view: 'text', type: 'string', },
  reportingUserTel: { title: '提报人联系方式', order: 3, view: 'number', type: 'number', },
  reportingUnit: { title: '提报单位', order: 4, view: 'text', type: 'string', },
  platformCompany: { title: '平台公司', order: 5, view: 'text', type: 'string', },
  platformCompanyId: { title: '接收平台公司(用户表id)', order: 6, view: 'text', type: 'string', },
  relatedProject: { title: '关联项目（取字典表sys_dict_item的id）', order: 7, view: 'text', type: 'string', },
  demandRemark: { title: '需求备注', order: 8, view: 'text', type: 'string', },
  demandPlanId: { title: '劳务需求表/设备需求表demand_plan_id', order: 9, view: 'text', type: 'string', },
  processInstanceId: { title: 'process_instance_id', order: 10, view: 'text', type: 'string', },
  processKey: { title: 'process_key', order: 11, view: 'text', type: 'string', },
  processStatus: { title: 'process_status', order: 12, view: 'text', type: 'string', },
  processLocation: { title: 'process_location', order: 13, view: 'text', type: 'string', },
  demandPlan: { title: '需求计划(目前只有月计划)', order: 14, view: 'text', type: 'string', },
  demandPlanMonth: { title: '需求计划月份', order: 15, view: 'text', type: 'string', },

};



//流程表单数据
export const formBpmSchema = ({ judgeIf, judeRequired, judgeRead }): FormSchema[] => [
  {
    label: '需求计划编号',
    field: 'demandPlanCode',
    filedkey: 'cgcj_demand_plan_demand_plan_code',
    // 新增时隐藏，编辑时显示
    ifShow: ({ model }) => {
      console.log('model', model)
      // 判断是否存在id字段，如果存在则为编辑状态，显示该字段
      return !!model.id;
    },
    // 编辑时显示但只读
    dynamicDisabled: () => {
      // 始终返回true，使该字段为只读状态
      return true;
    },
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [];
    },
  },
  {
    label: '需求计划类型',
    field: 'demandPlanType',
    filedkey: 'cgcj_demand_plan_demand_plan_type',
    ifShow: ({ schema }) => {
      return judgeIf(schema.filedkey, true);
    },
    required: ({ schema }) => {
      return judeRequired(schema.filedkey, true);
    },
    dynamicDisabled: ({ schema }) => {
      return judgeRead(schema.filedkey, false);
    },
    component: 'Select',
    dynamicRules: ({ model, schema }) => {
      return [
      ];
    },
    componentProps: {
      options: [
        {
          label: '劳务需求',
          value: 0
        },
        {
          label: '设备需求',
          value: 1
        }
      ]
    }
  },
  {
    label: '提报单位',
    field: 'reportingUnit',
    filedkey: 'cgcj_demand_plan_reporting_unit',
    ifShow: ({ schema }) => {
      return judgeIf(schema.filedkey, true);
    },
    required: ({ schema }) => {
      return judeRequired(schema.filedkey, false);
    },
    dynamicDisabled: ({ schema }) => {
      return judgeRead(schema.filedkey, false);
    },
    component: 'Input',

  },
  {
    label: '接收平台公司',
    field: 'platformCompany',
    filedkey: 'cgcj_demand_plan_platform_company',
    ifShow: ({ schema }) => {
      return judgeIf(schema.filedkey, true);
    },
    required: ({ schema }) => {
      return judeRequired(schema.filedkey, false);
    },
    dynamicDisabled: ({ schema }) => {
      return judgeRead(schema.filedkey, false);
    },
    component: 'Input',
  },
  {
    label: '关联项目',
    field: 'relatedProject',
    filedkey: 'cgcj_demand_plan_related_project',
    ifShow: ({ schema }) => {
      return judgeIf(schema.filedkey, true);
    },
    required: ({ schema }) => {
      return judeRequired(schema.filedkey, false);
    },
    dynamicDisabled: ({ schema }) => {
      return judgeRead(schema.filedkey, false);
    },
    component: 'Input',
  },
  {
    label: '需求备注',
    field: 'demandRemark',
    filedkey: 'cgcj_demand_plan_demand_remark',
    ifShow: ({ schema }) => {
      return judgeIf(schema.filedkey, true);
    },
    required: ({ schema }) => {
      return judeRequired(schema.filedkey, false);
    },
    dynamicDisabled: ({ schema }) => {
      return judgeRead(schema.filedkey, false);
    },
    component: 'Input',

  },
  {
    label: '需求计划月份',
    field: 'demandPlanMonth',
    filedkey: 'cgcj_demand_plan_demand_plan_month',
    ifShow: ({ schema }) => {
      return judgeIf(schema.filedkey, true);
    },
    required: ({ schema }) => {
      return judeRequired(schema.filedkey, false);
    },
    dynamicDisabled: ({ schema }) => {
      return judgeRead(schema.filedkey, false);
    },
    component: 'Input',

  }
];

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData, { judgeIf, judeRequired, judgeRead }): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formBpmSchema({ judgeIf, judeRequired, judgeRead });
}


export const approvalRunTaskBo = {
  task_instance_id: '',
  command_id: '',
  command_type: '',
  task_comment: '',
  transfer_user_id: '',
  revoke_task_id: '',
  endorsement_user_id_list: '',
  notice_user_id_list: '',
  roll_back_node_id: '',
  attachment_id: '',
  sureMessage: '',
  optional_node_assignee: {},
};